/*
 * Copyright (C) 2013 Framework-Base Project
 *               Author: Thunder
 *               Date: 2013年12月26日
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.jfshop.framework.util;

/**
 * 
 * Name: StringUtil.java
 * ProjectName: [Framework-Base]
 * Package: [com.grandthink.framework.util.StringUtil.java]
 * Description: 字符串工具类  
 * 
 * @since JDK1.6
 * @see
 * @version [v1.0]
 *
 * Author: @author: Thunder
 * Date: 2013年12月26日 下午3:23:38
 *
 * Update-User: @author
 * Update-Time:
 * Update-Remark:
 * 
 * Check-User:
 * Check-Time:
 * Check-Remark:
 * 
 * Company: GrandThink
 * Copyright: GrandThink
 */
public final class StringUtil {
	
	private StringUtil() {
	}
	
	/**
	 * 判断一个字符串是否为空字符串
	 * NOTIC: 如果源字符串为null, 会抛出一个 @see IllegalArgumentException
	 * @param str                   源字符串
	 * @return                      是否为空字符串
	 */
	public static boolean isEmpty(String str) {
		if (str == null) throw new IllegalArgumentException();
		return (str.length() == 0 || "".equals(str)) ? true : false;
	}
	
	/**
	 * 判断一个字符串是否为空字符串或者null
	 * @param str                   源字符串
	 * @return                      是否为空字符串或者null
	 */
	public static boolean isEmptyOrNull(String str) {
		return (str == null || isEmpty(str)) ? true : false;
	}
	
	/**
	 * 判断一个字符串是否为空字符串或者null或者字符串是'null'
	 * @param str                   源字符串
	 * @return                      是否为空字符串或者null或者为'null'
	 */
	public static boolean isEmptyOrNullOrStringNull(String str) {
		return (isEmptyOrNull(str) || (str != null && str.equals("null"))) ? true : false;
	}

	/**
	 * 判断一个字符串是否不为空字符串
	 * @param str            源字符串
	 * @return               true or false
	 */
	public static boolean isNotEmpty(String str) {
		return !isEmptyOrNullOrStringNull(str);
	}

}
